package com.glory.hikvisionmobile.adapter;

import android.view.View;
import android.widget.CheckBox;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.hikvisionmobile.R;
import com.glory.hikvisionmobile.bean.from.UserBean;

import java.util.List;

/**
 * FileName: PopListAdapter
 * Author: XJH
 * Date: 2020/3/6 19:32
 * Description: popAdapter
 * History:
 */
public class PopListAdapter extends BaseQuickAdapter<UserBean, BaseViewHolder> {
    public PopListAdapter(@Nullable List<UserBean> data) {
        super(R.layout.item_pop, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, UserBean item) {
        helper.setText(R.id.tvStr,item.getDescription());
        CheckBox cbChoose = helper.getView(R.id.cbChoose);
        if (helper.getAdapterPosition() == 0){
            cbChoose.setVisibility(View.GONE);
        }
        cbChoose.setChecked(item.isChecked());
        cbChoose.setTag(helper.getAdapterPosition());
        cbChoose.setOnClickListener(view -> item.setChecked(((CheckBox)view).isChecked()));

    }
}